<!DOCTYPE html>
<html>
<head lang="zh-CN">
    <meta charset="UTF-8">
    <title>NameSpace</title>
    <script src="/javascripts/socket.io.js"></script>
</head>
<body>
    <button onclick="connectChat1()">connectChat1</button>
    <button onclick="connectChat2()">connectChat2</button>
    <button onclick="sendChat1()">sendChat1</button>
    <button onclick="sendChat2()">sendChat2</button>

    <script>
        var chat1Socket,chat2Socket;

        function connectChat1() {
            chat1Socket = io("http://192.168.1.65/chat1");
            chat1Socket.on('connect', function () {
                console.info('chat1 connected');
            });

            chat1Socket.on('message', function (data) {
                console.info("chat1 " + data);
            });
        }

        function connectChat2() {
            chat2Socket = io("http://192.168.1.65/chat2");
            chat2Socket.on('connect', function () {
                console.info('chat2 connected');
            });

            chat2Socket.on('message', function (data) {
                console.info("chat2 " + data);
            });
        }

        var jsonObject = {userName: 'lixuwei', message:'hi everyone!'};

        function sendChat1() {
            chat1Socket.emit('message', jsonObject);
        }

        function sendChat2() {
            chat2Socket.emit('message', jsonObject);
        }

    </script>
</body>
</html>